- if intervals.size > 1
  .period-selector
    = link_to("datetime.periods.today".t, { current_period: Date.today, current_period_interval: period_interval }, class: 'btn today-period-btn')

.btn-group.period-selector
  - previous_period = current_period - 1.send(period_interval)
  - url_params = {}
  - url_params[:current_period] = previous_period
  - url_params[:current_campaign] = previous_period.year if period_interval == :year
  - params.each do |param|
    - url_params[param[0]] = param[1] if param[0].to_sym != :current_campaign && param[0].to_sym != :current_period
  = link_to('', url_params, class: 'btn btn-previous icn icn-only')


  - url_params = {}
  - if period_interval == :year
    - url_params = { controller: '/backend/campaigns', action: :show, id: current_campaign }
  :ruby
    displayed_period = if period_interval == :day
                         current_period.l
                       elsif period_interval == :week
                         :manual_period.tl(start: current_period.at_beginning_of_week.l, finish: current_period.at_end_of_week.l)
                       elsif period_interval == :month
                         current_period.l(format: :short_month)
                       else
                         current_period.year.to_s
                       end

  - if intervals.size > 1
    .btn.btn-group
      = content_tag(:button, nil, { class: "btn btn-with-intervals period #{period_interval}", "data-toggle": "dropdown" }) do
        %span= displayed_period
        %span.caret
      = content_tag(:ul, nil, class: "dropdown-menu interval-menu") do
        - intervals.each do |interval|
          = content_tag(:li, nil, class: "") do
            - classes = 'period-interval '
            - classes << 'active' if period_interval == interval
            = link_to("datetime.periods.#{interval}".t, { current_period_interval: interval, current_campaign: current_period.year }, class: classes)
  - else
    = link_to(displayed_period, url_params, class: "btn period #{period_interval}")


  - next_period = current_period + 1.send(period_interval)
  - url_params = {}
  - url_params[:current_period] = next_period
  - url_params[:current_campaign] = next_period.year if period_interval == :year
  - params.each do |param|
    - url_params[param[0]] = param[1] if param[0].to_sym != :current_campaign && param[0].to_sym != :current_period
  = link_to('', url_params, class: 'btn btn-next icn icn-only')
